import math
def Csum(num1,num2):
    return num1+num2
def Csub(num1,num2):
    return num1-num2
def Cmulti(num1,num2):
    return num1*num2
def power_cal(num1, num2):
    return num1 ** num2
def sin_cal(num):
    return math.sin(num)
def cos_cal(num):
    return math.cos(num)
def tan_cal(num):
    if(math.cos(num)==0):
        print("正切分母不能为0")
        return 0
    return math.tan(num)
def Cdiv(num1,num2):
    if(num2==0):
        print("分母不能为0")
        return 0
    else:
        return num1/num2
def logab(a,b):
    return math.log(a,b)
def Crem(num1, num2):
    if num2 == 0:
        print("取余运算中除数不能为0")
        return 0
    return num1 % num2
def mo(num):
    return abs(num)
    #abs为复数取模公式
print("""
      欢迎使用计算机，本计算机功能众多；
      可支持整数的 加+，减-，乘 *，除 /，对数运算 log ，乘方运算**，取余 %，余弦 cos 正弦sin正切 tan运算；
      也可支持复数的+，减-，乘*，除/ ，乘方**， ||（模运算）运算。
      创建者：GC
      """)
flag=True
while flag:
    if input("请选择复数（1）还是整数（2）\n")=="2":
        num1=int(input("请输入一个数"))
        num2=int(input("请输入另一个数"))
        choice = input("请选择 加+，减-，乘 *，除 /，对数运算 log ，乘方运算**，取余 %，余弦 cos 正弦sin正切 tan运算")
    else :
        num1 = complex(input("请输入一个数"))
        num2 = complex(input("请输入另一个数"))
        choice=input("请选择加+，减-，乘*，除/ ，乘方**， ||（模运算）运算")
    if choice=="+":
        print("num1",choice,"num2=",Csum(num1,num2))
    elif choice == "-":
        print("num1", choice, "num2=", Csub(num1, num2))
    elif choice == "*":
        print("num1", choice, "num2=", Cmulti(num1, num2))
    elif choice=="/":
        print("num1",choice,"num2=",Cdiv(num1,num2))
    elif choice == "log":
        print("log以", num1,"为底",num2,"的对数为", logab(num2, num1))
    elif choice == "**":
        print("num1", choice, "num2 = ", power_cal(num1, num2))
    elif choice == "%":
        print("num1", choice, "num2 = ", Crem(num1, num2))
    elif choice=="sin":
        print(choice,"num1=",sin_cal(num1),"\n",choice,"num2=",sin_cal(num2))
    elif choice == "cos":
        print(choice, "num1=", cos_cal(num1), "\n", choice, "num2=", cos_cal(num2 ))
    elif choice == "tan":
        print(choice, "num1=", tan_cal(num1), "\n", choice, "num2=", tan_cal(num2))
    elif choice=="||":
        print("num1的模为",mo(num1),"num2的模为",mo(num2))
    conti=input("如果还要继续，请输入y或Y,否则输入n")
    if conti=="Y" or conti=="y":
        flag=True
    else:
        flag=False
